<template>
  <view class="container">
    <view class="header">
      <text class="title">登录</text>
    </view>
    
    <view class="form-container">
      <view class="input-group">
        <text class="label">请输入用户名</text>
        <input 
          class="input" 
          type="text" 
          placeholder="请输入用户名"
          v-model="username"
          placeholder-class="placeholder"
        />
      </view>
      
      <view class="input-group">
        <text class="label">请输入密码</text>
        <input 
          class="input" 
          type="password" 
          placeholder="请输入密码"
          v-model="password"
          placeholder-class="placeholder"
        />
      </view>
      
      <button 
        class="login-btn" 
        :class="{ 'active': username && password }"
        :disabled="!username || !password"
        @tap="handleLogin"
      >
        登录
      </button>
      
      <view class="register-link">
        <text class="register-text">没有账号？</text>
        <navigator 
          url="/pages/register/register" 
          open-type="navigate"
          class="link"
        >
          去注册
        </navigator>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    handleLogin() {
      console.log("登录信息:", this.username, this.password);
      
      uni.switchTab({
        url: '/pages/cardViewPage/cardViewPage',
        success: () => {
          console.log("跳转成功");
        },
        fail: (err) => {
          console.error("跳转失败:", err);
          uni.navigateTo({
            url: '/pages/cardViewPage/cardViewPage'
          });
        }
      });
    },
    
    goDetailPage(e) {
      if (typeof e === 'string') {
        uni.navigateTo({
          url: '/pages/' + e + '/' + e
        });
      } else {
        uni.navigateTo({
          url: e.url
        });
      }
    }
  }
}
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background: #fff;
  padding: 40rpx;
}

.header {
  margin-top: 120rpx;
  margin-bottom: 80rpx;
}

.title {
  font-size: 48rpx;
  font-weight: bold;
  color: #333;
}

.form-container {
  width: 100%;
  max-width: 600rpx;
  background: #f8f9fa;
  border-radius: 20rpx;
  padding: 60rpx 40rpx;
  box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
}

.input-group {
  margin-bottom: 50rpx;
}

.label {
  display: block;
  font-size: 28rpx;
  color: #333;
  margin-bottom: 20rpx;
  font-weight: 500;
}

.input {
  width: 100%;
  height: 80rpx;
  border: 2rpx solid #e0e0e0;
  border-radius: 12rpx;
  padding: 0 24rpx;
  font-size: 28rpx;
  transition: border-color 0.3s;
}

.input:focus {
  border-color: #667eea;
}

.placeholder {
  color: #999;
  font-size: 28rpx;
}

.login-btn {
  width: 100%;
  height: 88rpx;
  background: #e0e0e0;
  border-radius: 12rpx;
  border: none;
  color: #999;
  font-size: 32rpx;
  font-weight: 500;
  margin-top: 20rpx;
  transition: all 0.3s;
}

.login-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 6rpx 20rpx rgba(102, 126, 234, 0.4);
}

.login-btn.active:active {
  transform: translateY(2rpx);
  box-shadow: 0 4rpx 15rpx rgba(102, 126, 234, 0.3);
}

.register-link {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 40rpx;
}

.register-text {
  font-size: 28rpx;
  color: #666;
}

.link {
  color: #667eea;
  font-size: 28rpx;
  margin-left: 10rpx;
  text-decoration: none;
}
</style>